package com.xm.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.xm.entity.Banners;
import com.xm.entity.LianXi;
import com.xm.uti.DBManager;
import com.xm.uti.QueryDataResult;
/**
 * 联系信息持久层
 * @author kh
 *
 */
public class LianXiDaoImpl {
	
	 /**
	   * 单查
	   * 查询联系信息
	   * @param id
	   * @return
	   */
	  public ArrayList<LianXi> getCom() {
	    String sql = "select * from lianXi";
	    System.out.println("执行的sql语句是" + sql);
	    QueryDataResult execQuery = DBManager.executeQuery(sql);
	    ArrayList<LianXi> list = new ArrayList<LianXi>();
	    if (execQuery != null) {
	      ResultSet rs = execQuery.rs;
	      try {
	        while (rs.next()) {
	          LianXi e = new LianXi();
	          e.setId(rs.getInt(1));
	          e.setTels(rs.getString("tels"));
	          e.setQqHao(rs.getString("qqHao"));
	          e.setWeiXin(rs.getString("weiXin"));
	          e.setGongZhongHao(rs.getString("gongZhongHao"));
	          list.add(e);
	        }
	      } catch (SQLException e) {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
	      } finally {
	        execQuery.close();
	      }
	    }
	    return list;
	  }

	  /**
		 * 修改
		 * 
		 * @param emp
		 * @return
		 */
		public boolean updateLIanxi(LianXi lianXi) {
			System.out.println("联系表的数据是" + lianXi);
			String sql = "update lianXi set tels='" + lianXi.getTels() + "',qqHao='" + lianXi.getQqHao() + "',weiXin='"
					+ lianXi.getWeiXin() + "',gongZhongHao='" + lianXi.getGongZhongHao() + "' where id =" + lianXi.getId();
			int i = DBManager.executeUpdate(sql);
			if (i > 0) {
				return true;
			}
			return false;
		}
	
}
